﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IOBusiness;
using System.Data;
using System.Text;
using IOBusiness.ClassLinq;
using IOBusiness.LinqDB;

namespace Indochinaodyssey.UserControl.NavigatorMenu
{
    public partial class MenuForProjectCruises : System.Web.UI.UserControl
    {
        SapaDBDataContext objContext = new SapaDBDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Text = menu();
        }

        public string menu() {
            
            StringBuilder menu = new StringBuilder();
            menu.Append("<div id=\"id_div1\">");
            menu.Append("<ul>");
            menu.Append("<li><a href=\"Default.aspx\"> | HOME | </a></li>");
            //------------------------------------
            menu.Append("<li> <a href=\"about-sapa.aspx\">ABOUT SAPA | </a>");
            menu.Append("<ul class=\"a1\">");
            menu.Append(getAboutUs());
            menu.Append("</ul>");
            menu.Append("</li>");
            //------------------------------------
            menu.Append("<li> <a href=\"hotel.aspx?catid=2\">ACCOMMODATION | </a>");
            menu.Append("<ul class=\"a1\">");
            menu.Append(getTheLoai(2));
            menu.Append("</ul>");
            menu.Append("</li>");
            //------------------------------------
            menu.Append("<li> <a href=\"sapa-tour.aspx?catid=3\">SAPA TOUR | </a>");
            menu.Append("<ul class=\"a1\">");
            menu.Append(getTheLoai(3));
            menu.Append("</ul>");
            menu.Append("</li>");
            //------------------------------------
            menu.Append("<li> <a href=\"pricing.aspx?catid=4\">PRICING | </a>");
            menu.Append("<ul class=\"a1\">");
            menu.Append(getTheLoai(4));
            menu.Append("</ul>");
            menu.Append("</li>");
            //------------------------------------
            menu.Append("<li> <a href=\"plan-your-trip.aspx?catid=5\">PLAN YOUR TRIP | </a>");
            menu.Append("<ul class=\"a1\">");
            menu.Append(getTheLoai(5));
            menu.Append("</ul>");
            menu.Append("</li>");
            //------------------------------------
            menu.Append("<li> <a href=\"gallery.aspx?catid=6\">PHOTO GALLERY | </a>");
            menu.Append("<ul class=\"a1\">");
            menu.Append(getTheLoai(6));
            menu.Append("</ul>");
            menu.Append("</li>");
            //------------------------------------
            menu.Append("<li> <a href=\"about-us.aspx?catid=7\">ABOUT US | </a>");
            menu.Append("<ul class=\"a1\">");
            menu.Append(getTheLoai(7));
            menu.Append("</ul>");
            menu.Append("</li>");
            menu.Append("<li> <a href=\"contact.aspx\">CONTACT US | </a>");        
            menu.Append("</li>");
            //------------------------------------
            menu.Append("</ul>");
            menu.Append("</div>");
            return menu.ToString();
        }

        private string getTheLoai(int idDanhMuc)
        {
            clsLqTheLoai theloai = new clsLqTheLoai();
            clsLqDanhMuc danhmuc = new clsLqDanhMuc();
            List<tblTheLoai> tbTheLoai = theloai.TheLoai_getTheLoaiByDanhMucId(idDanhMuc);
            List<tblDanhMuc> tbDanhMuc = danhmuc.DanhMuc_getDanhMuc(idDanhMuc);
            StringBuilder menu = new StringBuilder();
            for (int i = 0; i < tbTheLoai.Count; i++)
            {
                if (idDanhMuc == 2)
                    menu.Append("<li><a href=\"hotel.aspx?typeid=" + tbTheLoai.ElementAt<tblTheLoai>(i).ID
                    + "&catid=2" + "\">" 
                    + tbTheLoai.ElementAt<tblTheLoai>(i).TenTheLoai + "</a></li>");
                if (idDanhMuc == 3)
                    menu.Append("<li><a href=\"sapa-tour.aspx?typeid=" + tbTheLoai.ElementAt<tblTheLoai>(i).ID
                        + "&catid=3" + "\">"
                        + tbTheLoai.ElementAt<tblTheLoai>(i).TenTheLoai + "</a></li>");
                if (idDanhMuc == 4)
                    menu.Append("<li><a href=\"pricing.aspx?typeid=" + tbTheLoai.ElementAt<tblTheLoai>(i).ID
                        + "&catid=4" + "\">"
                        + tbTheLoai.ElementAt<tblTheLoai>(i).TenTheLoai + "</a></li>");
                if (idDanhMuc == 5)
                    menu.Append("<li><a href=\"plan-your-trip.aspx?typeid=" + tbTheLoai.ElementAt<tblTheLoai>(i).ID
                        + "&catid=5" + "\">"
                        + tbTheLoai.ElementAt<tblTheLoai>(i).TenTheLoai + "</a></li>");
                if (idDanhMuc == 6)
                    menu.Append("<li><a href=\"gallery.aspx?typeid=" + tbTheLoai.ElementAt<tblTheLoai>(i).ID
                        + "&catid=6" + "\">"
                        + tbTheLoai.ElementAt<tblTheLoai>(i).TenTheLoai + "</a></li>");
                if (idDanhMuc == 7)
                    menu.Append("<li><a href=\"about-us.aspx?typeid=" + tbTheLoai.ElementAt<tblTheLoai>(i).ID
                        + "&catid=7" + "\">"
                        + tbTheLoai.ElementAt<tblTheLoai>(i).TenTheLoai + "</a></li>");
            }
            return menu.ToString();
        }

        private String getAboutUs()
        {
            clsLqAbout about = new clsLqAbout();
            StringBuilder menu = new StringBuilder();
            List<tblAboutUS> tbAboutUs = about.About_getAll();
            for (int i = 0; i < tbAboutUs.Count; i++)
            {
                menu.Append("<li><a href=\"about-sapa.aspx?aboutid=" + tbAboutUs.ElementAt<tblAboutUS>(i).ID 
                    + "\">" 
                    + tbAboutUs.ElementAt<tblAboutUS>(i).TieuDe + "</a></li>");
            }
            return menu.ToString();
        }
    }
}